<template>
  <van-sticky>
    <van-nav-bar
      class="hmNavBar"
      @click-left="pathEvent"
      @click-right="clickRight"
    >
      <template #left v-if="left">
        <i class="iconfont f44">&#xe637;</i>
      </template>
      <template #title>
        <div class="title">
          {{ title }}
        </div>
      </template>
      <template #right>
        <div class="right">
          {{ right }}
        </div>
      </template>
    </van-nav-bar>
  </van-sticky>
</template>
<script>
export default {
  name: 'MyNavbar',
  props: {
    title: {
      // 中间标题
      type: String
    },
    path: {
      // 左箭头路径
      type: String
    },
    right: {
      // 右边文字
      type: String
    },
    left: {
      // 左箭头是否显示
      type: Boolean,
      default: true
    }
  },

  methods: {
    clickRight () {
      if (this.right !== '') {
        this.$emit('click-right')
      }
    },
    pathEvent () {
      if (this.path === '-1') {
        this.$router.go(-1)
      } else {
        this.$router.push(this.path)
      }
    }
  }
}
</script>
<style lang="less" scoped>
.hmNavBar {
  .f44 {
    font-size: 80px;
  }
  &::v-deep .van-nav-bar__left,
  &::v-deep .van-nav-bar__right {
    padding: 0;
  }
  .title {
    font-size: 36px;
    font-family: PingFangSC, PingFangSC-Semibold;
    font-weight: 600;
    text-align: center;
    color: #222222;
    line-height: 50px;
    letter-spacing: 0px;
  }
  .right {
    font-size: 28px;
    font-family: PingFangSC, PingFangSC-Regular;
    font-weight: 400;
    text-align: right;
    color: #181a39;
    line-height: 40px;
    letter-spacing: 0px;
    padding-right: 15px;
  }
}
</style>
